import { createRouter, createWebHistory } from 'vue-router'
import Login from '../views/Login.vue'
import Index from '../layout/Index.vue'
import Dashboard from '../views/Dashboard.vue'
import Settings from '../views/Settings.vue'

const routes = [
    {
        path: '/',
        redirect: '/login'
    },
    {
        path: '/login',
        name: 'Login',
        component: Login
    },
    {
        path: '/index',
        name: 'Index',
        component: Index,
        redirect: '/index/dashboard',  // 添加这行
        children: [
            {
                path: 'dashboard',
                component: Dashboard,
                meta: { title: '仪表盘' }
            },
            {
                path: 'pwd',
                component: () => import('../views/user/UserPwd.vue'),
                meta: { title: '修改密码' }
            },
            {
                path: 'user/list',
                component: () => import('../views/user/UserList.vue'),
                meta: { title: '用户列表' }
            },
            {
                path: 'user/add',
                component: () => import('../views/user/UserAdd.vue'),
                meta: { title: '新增用户' }
            },
            {
                path: 'user/info',
                component: () => import('../views/user/UserInfo.vue'),
                meta: { title: '个人中心' }
            },
            {
                path: 'settings',
                component: Settings,
                meta: { title: '系统设置' }
            }
        ]
    }
]

const router = createRouter({
    history: createWebHistory(),
    routes
})

export default router
